/*************************************************************************************
 *
 *  Revolution Engine
 *  Copyright (C) 2009 Felipe Apablaza
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 ************************************************************************************/

#ifndef __REVENG_OBJFACTORY_HPP__
#define __REVENG_OBJFACTORY_HPP__

#include <RevEng/DataTypes.hpp>

#include <map>
#include <list>
#include <typeinfo>

namespace RevEng
{
	class IObjCreator;
	class IObject;

	class ObjFactory
	{		
	private:
		static ObjFactory* s_pInstance;

	public:
		static ObjFactory* Instance();
		static void Delete();

	protected:
		typedef std::map<Enum, IObjCreator*> ObjCreatorReg;

	protected:
		ObjCreatorReg m_mCreators;

	public:
		ObjFactory();
		virtual ~ObjFactory() = 0;

		//Register a new object allocator
		void RegObjCreator( IObjCreator* Creator );

		//Create a new object of the specified type
		IObject* New( Enum ClassId );

		//Return the type_info for the specified type
		const std::type_info& GetTypeInfo( Enum ClassId ) const;
	};

	inline ObjFactory::ObjFactory()
	{
	}
}

#endif	//__REVENG_OBJFACTORY_HPP__
